<template>
	<view class="">
		<view class="form-body">
			<u-form labelPosition="left" :model="formData" ref="form" labelWidth="auto"
				errorType="toast">
				<u-form-item label="方案名称" prop="formula" borderBottom>
					<u-input v-model="formData.formula" border="none" placeholder="建议输入12字以内" inputAlign="right"></u-input>
				</u-form-item>
				<u-form-item label="入股金额" prop="mergeLowCondition" borderBottom>
					<u-input v-model="formData.mergeLowCondition" border="none" inputAlign="right" type="number"></u-input>
				</u-form-item>
				<u-form-item label="消费分红" borderBottom>
					<view class="flex">
						<view class="">
							<u-input v-model="formData.rewardValue" type="number" border="none" placeholder="请输入数字"
								inputAlign="right"></u-input>
						</view>
						<u-radio-group v-model="formData.rewardUnit" placement="row">
							<u-radio activeColor="#fa436a" name="元" label="元"></u-radio>
							<u-radio activeColor="#fa436a" name="%" label="%"></u-radio>
						</u-radio-group>
					</view>
				</u-form-item>
				
				<u-form-item label="股本消费" borderBottom>
					<view class="flex justify-end">
						<view class="">
							<u-radio-group v-model="formData.canConsume" placement="row">
								<u-radio activeColor="#fa436a" name="1" label="允许"></u-radio>
								<u-radio activeColor="#fa436a" name="-1" label="禁止"></u-radio>
							</u-radio-group>
						</view>
					</view>
				</u-form-item>
				<u-form-item label="股本可退" borderBottom>
					<view class="flex justify-end">
						<view class="">
							<u-radio-group v-model="formData.canRefund" placement="row">
								<u-radio activeColor="#fa436a" name="1" label="允许"></u-radio>
								<u-radio activeColor="#fa436a" name="-1" label="禁止"></u-radio>
							</u-radio-group>
						</view>
					</view>
				</u-form-item>
				
			</u-form>
		</view>
		<view class="marginTop60">
			<u-button type="primary" color="#fa436a" text="保存" @click="submit"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isEdit: false,
				formData: {
					id:0,
					formula: "",
					name:'分红方案',
					code:'fenhong',
					status:1,
					mergeLowCondition: 0,
					mergeHighCondition:0,
					rewardValue:0,
					rewardUnit:'',
					canConsume:'1',
					canRefund:'1',
				}
			}
		},
		onLoad(option) {
			let that = this
			if (option.id) {
				uni.setNavigationBarTitle({
					title: "编辑方案",
				})
				this.isEdit = true
				this.getEdit(option.id)
			}
		},
		onReady() {
		},
		methods: {
			// topro(){
			// 	uni.navigateTo({
			// 		url:'/pages/selectPage/project?items='+ JSON.stringify(this.formData.items)
			// 	})
			// },
			getEdit(id) {
				let that = this
				this.$reqJsonPost('IncentivePolicyGetEdit', {
					id: id
				}).then(res => {
					this.formData = {
						id:res.data.id,
						formula: res.data.formula,
						mergeLowCondition: res.data.mergeLowCondition,
						mergeHighCondition:res.data.mergeHighCondition,
						rewardValue:res.data.rewardValue,
						rewardUnit:res.data.rewardUnit,
						canConsume:'1',
						canRefund:'1',
						name:'分红方案',
						code:'fenhong',
						status:1,
					}
					console.log("this.formData",this.formData);
				})
			},
			submit() {
				if (this.isEdit) {
					this.$reqJsonPost('IncentivePolicyDoEdit', {
						...this.formData,
					}).then(res => {
						uni.redirectTo({
							url:'/pages/shop/IncentivePolicy/index'
						})
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.form-body {
		padding: 20rpx 20rpx 0 20rpx;
		background-color: #fff;
	}

	.pro-box {
		.seims {
			font-size: 28rpx;
			padding: 20rpx;
			color: #999;
		}

		.pro-list {
			padding: 0 20rpx;
			margin-bottom: 8rpx;
			background-color: #fff;
			.delBtn {
				border: 1px #fa436a solid;
				color: #fa436a;
				font-size: 22rpx;
				padding: 0 20rpx;
				border-radius: 6rpx;
			}
		}
	}
	.marginTop60{ margin-top: 30rpx;}

</style>
